/*
 * 1.1
 * Implement an algorithm to determine if a string has all unique characters. What if you
 * can not use additional data structures?
 */
#include <stdio.h>
#include <string.h>

bool unique(const char *str)
{
    char elems[127] = { 0 };  // XXX: 255 should be better.
    for (int i = 0; i < strlen(str); i++) {
        if (elems[str[i]]) {
            return false;
        }
        elems[str[i]] = 1;
    }
    return true;
}

int main()
{
    bool b1 = unique("1112");
    bool b2 = unique("12345");
    printf("b1=%d,b2=%d\n", b1, b2);
}
